﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace DataObject.Category
{
    public class CategoryDAL
    {
        /***************************************
        = Back End
        -------------------------------------- */
        public static void Category_Create(CategoryObject o)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Category_Create", o.TypeId, o.ParentId, o.Priority, o.Name, o.Url.ToLower(), o.ImagePath, o.IsActive);
        }

        public static void Category_Update(CategoryObject o)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Category_Update", o.CategoryId, o.TypeId, o.ParentId, o.Priority, o.Name, o.Url.ToLower(), o.ImagePath, o.IsActive);
        }

        public static void Category_Delete(int categoryId)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Category_Delete", categoryId);
        }

        public static IDataReader Category_GetById(int categoryId)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Category_GetById", categoryId);
        }

        public static DataTable Category_GetListByType_ListId(int typeId, string fieldList, string lstCategory)
        {
            return SqlHelper.ExecuteDataset(Constants.ConnectionString, "Category_GetListByType_ListId", typeId, fieldList, lstCategory).Tables[0];
        }

        public static int Category_GetStatistic(int status)
        {
            return (int)SqlHelper.ExecuteScalar(Constants.ConnectionString, "Category_GetStatistic", status);
        }

        public static IDataReader Category_GetByParentId(int typeId, int parentId, int isActive)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Category_GetByParentId", typeId, parentId, isActive);
        }        

        /***************************************
        = Front End
        -------------------------------------- */
        public static IDataReader Category_GetByParentId_Filter(bool isFilter, int typeId, int parentId, int isActive)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Category_GetByParentId_Filter", isFilter, typeId, parentId, isActive);
        }
        
    }
}
